/**
 * ReportGear(2011)
 */
package com.reportgear.designer.startup;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

import com.reportgear.designer.DesignerPane;
import com.reportgear.designer.config.Log4jConfig;
import com.reportgear.designer.view.menu.DesignerMenu;
import com.reportgear.swing.util.GuiUtils;


/**
 * 设计器程序入口，启动设计器
 * 
 * @version 1.0 2011-3-14
 * @author <a herf="lexloo@gmail.com">lexloo</a>
 * @since Report 1.0
 * 
 */
public class StartDesigner {
	// 主框架
	private static JFrame frameMain;

	private static class DesignerFrame extends JFrame {
		/**
		 * UID
		 */
		private static final long serialVersionUID = -4619668464880485528L;

		private DesignerFrame() {
			this.initComponents();
		}

		/**
		 * 初始化
		 */
		private void initComponents() {
			this.setMinimumSize(new Dimension(400, 300));
			this.setLocation(0, 0);
			this.setTitle("报表设计器");
			this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			this.pack();
			this.setExtendedState(JFrame.MAXIMIZED_BOTH);

			this.setLayout(new BorderLayout());
			this.add(new DesignerPane(), BorderLayout.CENTER);
		}
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {

			@Override
			public void run() {
				try {
					UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
				} catch (Exception e) {
					e.printStackTrace();
				}

				// 设置输出定位
				// System.setOut(GuiPrintStream.getInstance());
				Log4jConfig.config();
				// GuiUtils.setupLookAndFeel();
				GuiUtils.setDefaultUIFont("宋体");

				frameMain = new DesignerFrame();
				 SwingUtilities.updateComponentTreeUI(frameMain);
				frameMain.setJMenuBar(new DesignerMenu());
				frameMain.setVisible(true);
				frameMain.toFront();
			}
		});
	}

}
